package com.yonyou.hxjy.utils;


import com.yonyou.hxjy.entity.YsQueryDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
  * @Author Huangwb
  * @Description YsQueryDto请求对象获取公共方法
  * @Date 2024/4/25 10:36
 **/
@Component
public class YsQueryDtoSingletonUtil {

    private static YsQueryDto ysQueryDto;

    @Value("${ys.config.tenantId}")
    private String tenantId;

    @Value("${ys.config.appKey}")
    private String appKey;

    @Value("${ys.config.appSecret}")
    private String appSecret;

    @Value("${ys.config.tokenUrl}")
    private String tokenUrl;

    @Value("${ys.config.gatewayUrl}")
    private String gatewayUrl;

    private YsQueryDtoSingletonUtil() {
        // 私有构造函数，防止外部实例化
    }
    
    @PostConstruct
    private void init() {
        ysQueryDto = new YsQueryDto(tenantId, appKey, appSecret, tokenUrl, gatewayUrl);
    }
    
    public static synchronized YsQueryDto getYsQueryDto() {
        return ysQueryDto;
    }
    
}